<?php
namespace Common\Model;

/**
 * 客栈表
 * @modify zhangzhen 2016-12-22 创建
 */

Class HotelSynModel extends \Common\Model\BaseModel
{
    protected $trueTableName = 'tb_hotel_syn';
    protected function _before_insert(&$data, $options) {
       // parent::_before_insert($data, $options);
    }
    /**
     * 客栈同步表
	 * @modify zhangzhen 2016-12-22  添加集群号  
     * @param  string   $name       客栈名
     * @param  integer   $cityId     城市id
     * @param  integer   $districtId 区id
	 * @param  string   $communityNo 集群号
     * @return boolean 添加结果
     */
    public function addInfo($hotelId,$communityNo,$masterentityId,$creator) {
        $data = array(
            'masterentity_id' => $masterentityId,
            'masterentity_no' => $communityNo,
            'hotelentity_id' => $hotelId,
        );
        if(isset($creator)){
            $data['creator'] = $creator;
            $data['operator'] = $creator;
        }
        $data['updatetime'] = date('Y-m-d H:i:s');

        $id = $this->add($data);
        return $id === false ? false : $id;
    }
    /**
     * 获取同步过的集群
     * @modify zhangzhen 2016-12-22 创建
     * @param  mixin   $hotelSynId     该表的id
     * @return array 信息
     */
    public function getInfoById($hotelSynId) {
		$option['id'] = $hotelSynId;
        return $this->where($option)->find();
    }
    /**
     * 获取同步过的集群
     * @modify zhangzhen 2016-12-22 创建
     * @param  id   $masterentityId      qrmaster集群id
     * @return array 信息
     */
    public function getInfoByMasterId($masterentityId) {
		$option['masterentity_id'] = $masterentityId;
        return $this->where($option)->find();
    }
	/**
     * 根据管理员获取同步过的集群
     * @modify zhangzhen 2016-12-22 创建
     * @param  id   $userId      管理员Id
     * @return array 信息
     */
    public function getInfoByUserId($userId) {
		$option['creator'] = $userId;
        return $this->where($option)->select();
    }
    /**
     * 根据酒店Id获取同步过的集群
     * @modify zhangzhen 2017-02-06 创建
     * @param  id   $hotelId      酒店id
     * @return array 信息
     */
    public function getInfoByHotelId($hotelId) {
        $option['hotelentity_id'] = $hotelId;
        return $this->where($option)->find();
    }

}
